/* hal_lptmr.h */
#ifndef __HAL_LPTMR_H__
#define __HAL_LPTMR_H__

#include "hal_common.h"

/* 定义计数时钟源 */
typedef enum
{
    eLPTMR_ClockSource_0 = 0U,
    eLPTMR_ClockSource_1 = 1U,
    eLPTMR_ClockSource_2 = 2U,

    /* For KE18F. */
    eLPTMR_ClockSource_PCC_Sel  = eLPTMR_ClockSource_0, /* not available in LLS and VLLS modes. */
    eLPTMR_ClockSource_LPO_1KHz = eLPTMR_ClockSource_1, /* not available in VLLS0 mode. */
    eLPTMR_ClockSource_ERCLK32K = eLPTMR_ClockSource_2, /* not available in VLLS0 mode when using 32 kHz oscillator. */

    eLPTMR_ClockSource_Unavailable = 4U
} LPTMR_ClockSource_T;

/* 定义计数时钟分频因子 */
typedef enum
{
    eLPTMR_ClockPreDiv_2     = 0U,
    eLPTMR_ClockPreDiv_4     = 1U,
    eLPTMR_ClockPreDiv_8     = 2U,
    eLPTMR_ClockPreDiv_16    = 3U,
    eLPTMR_ClockPreDiv_32    = 4U,
    eLPTMR_ClockPreDiv_64    = 5U,
    eLPTMR_ClockPreDiv_128   = 6U,
    eLPTMR_ClockPreDiv_256   = 7U,
    eLPTMR_ClockPreDiv_512   = 8U,
    eLPTMR_ClockPreDiv_1024  = 9U,
    eLPTMR_ClockPreDiv_2048  = 10U,
    eLPTMR_ClockPreDiv_4096  = 11U,
    eLPTMR_ClockPreDiv_8192  = 12U,
    eLPTMR_ClockPreDiv_16384 = 13U,
    eLPTMR_ClockPreDiv_32768 = 14U,
    eLPTMR_ClockPreDiv_65536 = 15U,
    eLPTMR_ClockPreDiv_Disabled = 16
} LPTMR_ClockPreDiv_T;

typedef struct
{
    LPTMR_ClockSource_T ClockSource; /* 计数时钟源 */
    LPTMR_ClockPreDiv_T ClockPreDiv; /* 计数时钟分频因子 */
} LPTMR_PitConfig_T;

/* Timer/Counter. */
void LPTMR_HAL_Reset(void);
bool LPTMR_HAL_ConfigPitMode(LPTMR_PitConfig_T *configPtr);
void LPTMR_HAL_SetTimeoutValue(uint16_t val);
bool LPTMR_HAL_IsTimeout(void);
void LPTMR_HAL_ClearTimeoutFlag(void);
void LPTMR_HAL_Start(void);
void LPTMR_HAL_Stop(void);

/* Interrupt. */
void LPTMR_HAL_SetIntEnabledOnTimeout(bool enInt);
void LPTMR_HAL_IRQHandlerHook(void);
void LPTMR_HAL_InstallCallbackOnTimeout(void (*func)(void));

#endif /* __LPTMR_H__ */

